<template>
	<view>
		<!-- <view class="" style="width: 100%;margin: 0 auto;display: flex;text-align: center;line-height: 100rpx;background-color: #FFFFFF;">
			<view @click="dibu(1)" style="flex: 1;position: relative;" :class="tabIndex==1?'active':'a'">
				审核通过
				<image v-if="tabIndex==1" src="https://static-1310167831.cos.ap-nanjing.myqcloud.com/uploads/20230411/2176b3fec852179c4610f402fdac0589.png" style="width: 100rpx;height: 12rpx;position: absolute;left:50%;bottom: 16rpx;transform: translateX(-50%);"  mode=""></image>
			</view>
			<view @click="dibu(0)" style="flex: 1;position: relative;" :class="tabIndex==0?'active':'a'">
				待审核
				<image v-if="tabIndex==0" src="https://static-1310167831.cos.ap-nanjing.myqcloud.com/uploads/20230411/2176b3fec852179c4610f402fdac0589.png" style="width: 100rpx;height: 12rpx;position: absolute;left: 50%;bottom: 16rpx;transform: translateX(-50%);"  mode=""></image>
			</view>
		</view> -->
		<view style="width: 92%;margin: 20rpx auto;">
			<view v-for="(item,index) in list" :key='index' style="background-color: #FFFFFF;border-radius: 20rpx;">
				<view  style="overflow: hidden;box-sizing: border-box;padding: 40rpx 30rpx;border-radius: 20rpx;margin-bottom: 10rpx;">
					<view style="width: 18%;float: left;">
						<image :src="item.client.avatar" style="width: 88rpx;height: 88rpx;border-radius: 50%;display: block;" mode=""></image>
					</view>
					<view style="width:30%;float: left;padding: 4rpx 0;">
						<view style="line-height: 40rpx;font-size: 30rpx;color: #000000;" class="yihang">
							{{item.client.name || item.client.nickname}}
						</view>
						<view style="line-height: 40rpx;font-size: 24rpx;color: #999999;" class="yihang">
							{{item.client.mobile || ''}}
						</view>
					</view>
					<view style="width: 52%;float: left;display: flex;">
						<view @click="tongguo(item.client_id,item.firm_id,index)" style="flex: 1;line-height: 40rpx;text-align: center;border-radius: 20rpx;color: #1fb0ac;font-size: 24rpx;margin-right: 20rpx;margin-top: 24rpx;border: 1px solid #1fb0ac;">
							移交管理
						</view>
						<view @click="jujue(item.client_id,item.firm_id,index)" style="flex: 1;line-height:40rpx;text-align: center;border-radius: 20rpx;color: #DD524D;font-size: 24rpx;margin-top: 24rpx;border: 1px solid #DD524D;">
							移除员工
						</view>
					</view>
				</view>
				<!-- <view v-if="tabIndex==0" style="width: 100%;box-sizing: border-box;padding: 0 30rpx;display: flex;padding-bottom: 30rpx;">
					<view @click="tongguo(item.id,index)" style="flex: 1;line-height: 60rpx;text-align: center;border-radius: 30rpx;background-color: #1fb0ac;color: #FFFFFF;font-size: 28rpx;margin-right: 20rpx;">
						通过
					</view>
					<view @click="jujue(item.id,index)" style="flex: 1;line-height: 60rpx;text-align: center;border-radius: 30rpx;background-color: #DD524D;color: #FFFFFF;font-size: 28rpx;">
						拒绝
					</view>
				</view> -->
			</view>

		</view>
		<view style="text-align: center;margin-top: 50rpx;">
			<image v-if="kk" :src="require('@/static/my/no-data.png')" style="width: 334rpx;"  mode="widthFix"></image>
			<view v-if="list.length==0" style="text-align: center;color: #999999;font-size: 30rpx;line-height: 60rpx;">
				暂无
			</view>
			<view v-if="list.length>0 && enmpy" style="text-align: center;color: #999999;font-size: 30rpx;line-height: 60rpx;width: 100%;">
				没有更多了
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				tabIndex:1,
				page: 1,
				kk:false,
				enmpy: false,
				list:[],
			}
		},
		onShow() {
			this.page= 1
			this.kk=false
			this.enmpy= false
			this.list=[]
			this.liebiao()
		},
		onReachBottom: function() {
			if (this.enmpy) {
				return
			} else {
				this.liebiao()
			}
		},
		methods:{
			dibu:function(index){
				this.tabIndex=index
				this.page=1
				this.enmpy=false
				this.kk=false
				this.list=[]
				this.liebiao()
			},
			liebiao:function(){
				this.post('api/firm/user',{status:this.tabIndex,page:this.page,limit:10},true).then(res=>{
					if(res.code==1){
						if(this.page==1){
							if (res.data.data== null || res.data.data.length == 0) {
								this.kk = true
								this.enmpy = true
								return
							} else if (res.data.data.length < 10) {
								this.enmpy = true
							}
						}else{
							if (res.data.data== null || res.data.data.length == 0) {
								this.enmpy = true
								return
							} else if (res.data.data.length < 10) {
								this.enmpy = true
							}
						}

						this.page++
						this.list.push(...res.data.data)
					}else{
						this.kk = true
						uni.showToast({
							title: res.msg,
							icon: "none",
							duration: 1000
						})
					}
				})
			},
			tongguo:function(id,did,index){
				let that=this
				uni.showModal({
					title: '提示',
					content: '您确定要移交管理吗？',
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
							that.post('api/firm/update_admin',{client_id:id,firm_id:did},true).then(res=>{
								console.log(res)
								if(res.code==1){
									uni.showToast({
										title: res.msg,
										icon: "none",
										duration: 1000
									})
									setTimeout(function(){
										uni.switchTab({
											url:'/pages/index/wode'
										})
									},1500)
								}else{
									uni.showToast({
										title: res.msg,
										icon: "none",
										duration: 1000
									})
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});

			},
			jujue:function(id,did,index){
				let that=this
				uni.showModal({
					title: '提示',
					content: '您确定要移除该员工吗？',
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
							that.post('api/firm/delete_user',{client_id:id,firm_id:did},true).then(res=>{
								console.log(res)
								if(res.code==1){
									uni.showToast({
										title: res.msg,
										icon: "none",
										duration: 1000
									})
									that.list.splice(index,1)
								}else{
									uni.showToast({
										title: res.msg,
										icon: "none",
										duration: 1000
									})
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});

			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #f5f5f5!important;
		font-family: Demibold;
	}
	.active{
		color: #1fb0ac;
		font-size: 30rpx;
	}
	.a{
		color: #666666;
		font-size: 26rpx;
	}
</style>
